﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Srvtools;
using System.Data;

public partial class ServicesSheet_SV_CarSubsidy : System.Web.UI.Page
{
    private Srvtools.WebDataSet WMaster;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitializeComponent();

            Master.DataSource = WMaster;


            MasterPage_MasterPage master = (MasterPage_MasterPage)this.Page.Master;
            master.HelpHref = "~/Help/ServicesSheet/设置私车公用人员.htm";
            master.PageName = "私车公用员工车辆管理";
            master.PicUrl = "";
            master.IntiBar();
        }
    }

    private void InitializeComponent()
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ServicesSheet_SV_CarSubsidy));
        this.WMaster = new Srvtools.WebDataSet();
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).BeginInit();
        // 
        // WMaster
        // 
        this.WMaster.Active = true;
        this.WMaster.AlwaysClose = false;
        this.WMaster.DeleteIncomplete = true;
        this.WMaster.Guid = null;
        this.WMaster.LastKeyValues = null;
        this.WMaster.Locale = new System.Globalization.CultureInfo("zh-CN");
        this.WMaster.PacketRecords = 100;
        this.WMaster.Position = -1;
        this.WMaster.RemoteName = "ServiceSheet.Services_SV_CarSubsidy";
        this.WMaster.ServerModify = true;
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).EndInit();

    }
    protected void wgvMaster_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void wgvMaster_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Invalid")
        {
            string id = e.CommandArgument.ToString();

            DataTable dt = ((WebDataSource)wgvMaster.DataSourceObject).InnerDataSet.Tables[0];
            DataRow[] dr = dt.Select("SubId = " + id);
            if (dr.Length > 0)
                dt.Rows.Remove(dr[0]);

            string UpdateSql = string.Format("update Services_SV_CarSubsidy set State={0} where SubId={1}", 0, id);

            object[] objParam = new object[1];
            objParam[0] = UpdateSql;

            object[] myRet = CliUtils.CallMethod("ServiceSheet", "ExecSqlNonQuery", objParam);


            if (myRet != null && (int)myRet[0] == 0)
            {
                bool boo = (bool)myRet[1];
                if (boo)
                    wgvMaster.DataBind();
                else
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('删除失败！')", true);
            }
        }
    }
}
